package main

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"news-manage/config"
	"news-manage/models"
	"news-manage/router"
)

func main() {
	conf, err := config.Init()
	if err != nil {
		return
	}
	db, err := gorm.Open(mysql.Open(conf.Mysql.Dsn))
	if err != nil {
		return
	}
	err = db.AutoMigrate(&models.Art{}, &models.User{})
	if err != nil {
		fmt.Println("失败")
		return
	}
	r := router.Init(db)
	r.Run(":8080")
}
